﻿<ResourceDictionary 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:sys="clr-namespace:System;assembly=mscorlib"
    xmlns:v="clr-namespace:ShredTheLog.Views;assembly=ShredTheLog.Views"
    xmlns:vm="clr-namespace:ShredTheLog.ViewModels;assembly=ShredTheLog.ViewModels"
    xmlns:cnv="clr-namespace:ShredTheLog.Converters;assembly=ShredTheLog.Converters"
    xmlns:c="clr-namespace:ShredTheLog.Controls;assembly=ShredTheLog.Controls"
    >

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="FlashMisc2.xaml"/>
        <ResourceDictionary Source="pack://application:,,,/ShredTheLog.Themes;component/AppIcon.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <Style x:Key="FlashWindowBaseStyle" TargetType="{x:Type Window}">
        <Style.Resources>
            <GridLength x:Key="WindowCornerLength">20</GridLength>
            
            <Style TargetType="{x:Type c:WindowTitleBar}">
                <Setter Property="FontSize" Value="15"/>
                <Setter Property="HorizontalContentAlignment" Value="Center"/>
            </Style>

            <Style x:Key="WindowTitleBarButton" TargetType="{x:Type Button}">
                <Setter Property="Foreground" Value="#545454"/>
                <Setter Property="BorderThickness" Value="1"/>
                <Setter Property="BorderBrush" Value="Transparent"/>
                
                <Style.Triggers>
                    <Trigger Property="IsMouseOver" Value="True">
                        <Setter Property="BorderBrush">
                            <Setter.Value>
                                <LinearGradientBrush>
                                    <GradientStop Offset="0" Color="#FCFCFC"/>
                                    <GradientStop Offset="0.499" Color="#FCFCFC"/>
                                    <GradientStop Offset="0.5" Color="#7C7C7C"/>
                                    <GradientStop Offset="1" Color="#7C7C7C"/>
                                </LinearGradientBrush>
                            </Setter.Value>
                        </Setter>
                    </Trigger>
                    <Trigger Property="IsPressed" Value="True">
                        <Setter Property="Background" Value="#DEDEDE"/>
                        <Setter Property="BorderBrush">
                            <Setter.Value>
                                <LinearGradientBrush>
                                    <GradientStop Offset="0" Color="#6F6F6F"/>
                                    <GradientStop Offset="0.499" Color="#6F6F6F"/>
                                    <GradientStop Offset="0.5" Color="#FCFCFC"/>
                                    <GradientStop Offset="1" Color="#FCFCFC"/>
                                </LinearGradientBrush>
                            </Setter.Value>
                        </Setter>
                    </Trigger>
                </Style.Triggers>
            </Style>

            <Style TargetType="{x:Type c:WindowMinimizeButton}" BasedOn="{StaticResource WindowTitleBarButton}"/>
            <Style TargetType="{x:Type c:WindowMaximizeButton}" BasedOn="{StaticResource WindowTitleBarButton}"/>
            <Style TargetType="{x:Type c:WindowCloseButton}" BasedOn="{StaticResource WindowTitleBarButton}"/>

        </Style.Resources>

        <Setter Property="Icon" Value="{StaticResource AppIcon}"/>
        <Setter Property="c:WindowIcon.Icon" Value="{StaticResource AppIcon}"/>
        
        <Setter Property="WindowStyle" Value="None"/>
        <Setter Property="AllowsTransparency" Value="True"/>

        <Setter Property="Background" Value="{StaticResource LightGrayBackgroundBrush}"/>
        <Setter Property="BorderThickness" Value="2"/>
        <Setter Property="BorderBrush" Value="#809D9D9D"/>
        <Setter Property="Padding" Value="5"/>
        <Setter Property="Margin" Value="0, 0, 0, 7"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Window}">
                    <AdornerDecorator>
                        <Grid>
                            <!--Тень под окном-->
                            <Border VerticalAlignment="Bottom" HorizontalAlignment="Stretch" Height="10" Background="{TemplateBinding Background}" CornerRadius="0, 0, 5, 5" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="Transparent" Margin="{TemplateBinding Margin}">
                                <Border.Effect>
                                    <DropShadowEffect Direction="-90" Color="Black" ShadowDepth="5" Opacity="0.5"/>
                                </Border.Effect>
                            </Border>
                            
                            <Border x:Name="resizeBorder" Background="{TemplateBinding Background}" CornerRadius="5" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Margin="{TemplateBinding Margin}">
                                <Grid>
                                    <UIElement.Clip>
                                        <MultiBinding Converter="{x:Static cnv:RectangleGeometryConverter.Default}">
                                            <Binding ElementName="resizeBorder" Path="ActualWidth"/>
                                            <Binding ElementName="resizeBorder" Path="ActualHeight"/>
                                            <Binding ElementName="resizeBorder" Path="CornerRadius.BottomLeft"/>
                                            <Binding ElementName="resizeBorder" Path="BorderThickness.Left"/>
                                        </MultiBinding>
                                    </UIElement.Clip>

                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="{StaticResource WindowCornerLength}"/>
                                        <ColumnDefinition Width="*"/>
                                        <ColumnDefinition Width="{StaticResource WindowCornerLength}"/>
                                    </Grid.ColumnDefinitions>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="{StaticResource WindowCornerLength}"/>
                                        <RowDefinition Height="*"/>
                                        <RowDefinition Height="{StaticResource WindowCornerLength}"/>
                                    </Grid.RowDefinitions>

                                    <c:WindowTopBorder Grid.Column="1" Grid.Row="0"/>
                                    <c:WindowBottomBorder Grid.Column="1" Grid.Row="2"/>
                                    <c:WindowLeftBorder Grid.Column="0" Grid.Row="1"/>
                                    <c:WindowRightBorder Grid.Column="2" Grid.Row="1"/>
                                    <c:WindowTopLeftCorner Grid.Column="0" Grid.Row="0"/>
                                    <c:WindowTopRightCorner Grid.Column="2" Grid.Row="0"/>
                                    <c:WindowBottomLeftCorner Grid.Column="0" Grid.Row="2"/>
                                    <c:WindowBottomRightCorner Grid.Column="2" Grid.Row="2"/>

                                    <DockPanel Grid.ColumnSpan="3" Grid.RowSpan="3" Margin="{TemplateBinding Padding}">
                                        <c:WindowTitleBar DockPanel.Dock="Top">
                                            <c:WindowTitleBar.Title>
                                                <TextBlock Text="{TemplateBinding Title}" TextTrimming="CharacterEllipsis"/>
                                            </c:WindowTitleBar.Title>
                                        </c:WindowTitleBar>
                                        <ContentPresenter Content="{TemplateBinding Content}"/>
                                    </DockPanel>

                                    <ResizeGrip x:Name="WindowResizeGrip" Grid.ColumnSpan="3" Grid.RowSpan="3" HorizontalAlignment="Right" VerticalAlignment="Bottom" Visibility="Collapsed" IsTabStop="false"/>
                                </Grid>
                            </Border>
                        </Grid>
                    </AdornerDecorator>
                    <ControlTemplate.Triggers>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="Window.ResizeMode" Value="CanResizeWithGrip"/>
                                <Condition Property="Window.WindowState" Value="Normal"/>
                            </MultiTrigger.Conditions>
                            <Setter TargetName="WindowResizeGrip" Property="Visibility" Value="Visible"/>
                        </MultiTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type v:MainView}" BasedOn="{StaticResource FlashWindowBaseStyle}">
        <Setter Property="Background" Value="White"/>
        <Setter Property="Width" Value="950"/>
        <Setter Property="Height" Value="740"/>
        <Setter Property="MinWidth" Value="750"/>
        <Setter Property="MinHeight" Value="550"/>
        <Setter Property="Title" Value="{c:LocalizedString s_AppTitle}"/>
    </Style>

    <Style TargetType="{x:Type v:UserProfileView}" BasedOn="{StaticResource FlashWindowBaseStyle}">
        <Setter Property="Width" Value="550"/>
        <Setter Property="Height" Value="300"/>
        <Setter Property="MinWidth" Value="550"/>
        <Setter Property="MinHeight" Value="300"/>
        <Setter Property="Title" Value="{Binding Path=Name, StringFormat={c:LocalizedString s_Profile}}"/>
    </Style>

    <Style TargetType="{x:Type v:TextChatRoomView}" BasedOn="{StaticResource FlashWindowBaseStyle}">
        <Style.Resources>
            <Style TargetType="{x:Type c:WindowTitleBar}" BasedOn="{StaticResource {x:Type c:WindowTitleBar}}">
                <Setter Property="Background" Value="{StaticResource HeaderTextBrush}"/>
                <Setter Property="Foreground" Value="White"/>
                <Setter Property="FontSize" Value="15"/>
                <Setter Property="HorizontalContentAlignment" Value="Center"/>
            </Style>

            <Style x:Key="WindowTitleBarButton" TargetType="{x:Type Button}">
                <Setter Property="Foreground" Value="#1E2E3B"/>
                <Setter Property="BorderThickness" Value="1"/>
                <Setter Property="BorderBrush" Value="Transparent"/>

                <Style.Triggers>
                    <Trigger Property="IsMouseOver" Value="True">
                        <Setter Property="BorderBrush">
                            <Setter.Value>
                                <LinearGradientBrush>
                                    <GradientStop Offset="0" Color="#ADC5D8"/>
                                    <GradientStop Offset="0.499" Color="#ADC5D8"/>
                                    <GradientStop Offset="0.5" Color="#2A4356"/>
                                    <GradientStop Offset="1" Color="#2A4356"/>
                                </LinearGradientBrush>
                            </Setter.Value>
                        </Setter>
                    </Trigger>
                    <Trigger Property="IsPressed" Value="True">
                        <Setter Property="Background" Value="#407096"/>
                        <Setter Property="BorderBrush">
                            <Setter.Value>
                                <LinearGradientBrush>
                                    <GradientStop Offset="0" Color="#20384B"/>
                                    <GradientStop Offset="0.499" Color="#20384B"/>
                                    <GradientStop Offset="0.5" Color="#A4BED3"/>
                                    <GradientStop Offset="1" Color="#A4BED3"/>
                                </LinearGradientBrush>
                            </Setter.Value>
                        </Setter>
                    </Trigger>
                </Style.Triggers>
            </Style>

            <Style TargetType="{x:Type c:WindowMinimizeButton}" BasedOn="{StaticResource WindowTitleBarButton}"/>
            <Style TargetType="{x:Type c:WindowMaximizeButton}" BasedOn="{StaticResource WindowTitleBarButton}"/>
            <Style TargetType="{x:Type c:WindowCloseButton}" BasedOn="{StaticResource WindowTitleBarButton}"/>

            <Style TargetType="{x:Type c:WindowBottomRightCorner}" BasedOn="{StaticResource {x:Type c:WindowBottomRightCorner}}">
                <Setter Property="Cursor" Value="SizeNWSE"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type c:WindowBottomRightCorner}">
                            <Border>
                                <Border.Background>
                                    <LinearGradientBrush StartPoint="0, 0" EndPoint="1, 1">
                                        <GradientStop Offset="0" Color="Transparent"/>
                                        <GradientStop Offset="0.499" Color="Transparent"/>
                                        <GradientStop Offset="0.500" Color="Black"/>
                                        <GradientStop Offset="0.562" Color="Transparent"/>
                                        <GradientStop Offset="0.625" Color="Gray"/>
                                        <GradientStop Offset="0.687" Color="Transparent"/>
                                        <GradientStop Offset="0.750" Color="Gray"/>
                                        <GradientStop Offset="0.812" Color="Transparent"/>
                                        <GradientStop Offset="0.875" Color="Gray"/>
                                        <GradientStop Offset="1" Color="Transparent"/>
                                    </LinearGradientBrush>
                                </Border.Background>
                            </Border>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </Style.Resources>

        <Setter Property="ResizeMode" Value="CanResize"/>
        <Setter Property="Padding" Value="0"/>
        <Setter Property="Background" Value="{StaticResource GrayBackgroundBrush}"/>
        <Setter Property="Width" Value="620"/>
        <Setter Property="Height" Value="400"/>
        <Setter Property="MinWidth" Value="620"/>
        <Setter Property="MinHeight" Value="400"/>
        <Setter Property="Title" Value="{Binding Path=RoomName, Converter={x:Static cnv:RoomConverter.Default}}"/>
    </Style>

    <Style TargetType="{x:Type v:AboutView}" BasedOn="{StaticResource FlashWindowBaseStyle}">
        <Setter Property="ResizeMode" Value="NoResize"/>
        <Setter Property="SizeToContent" Value="WidthAndHeight"/>
        <Setter Property="Title" Value="{Binding Path=Product, StringFormat={c:LocalizedString s_AboutDialogTitle}}"/>
    </Style>

    <Style TargetType="{x:Type v:LogInView}" BasedOn="{StaticResource FlashWindowBaseStyle}">
        <Setter Property="Width" Value="300"/>
        <Setter Property="Height" Value="150"/>
        <Setter Property="MinWidth" Value="300"/>
        <Setter Property="MinHeight" Value="150"/>
        <Setter Property="ResizeMode" Value="NoResize"/>
        <Setter Property="ShowInTaskbar" Value="True"/>
        <Setter Property="SizeToContent" Value="Height"/>
        <Setter Property="Title" Value="{c:LocalizedString s_LogIn}"/>
    </Style>

    <Style TargetType="{x:Type v:SettingsView}" BasedOn="{StaticResource FlashWindowBaseStyle}">
        <Setter Property="Width" Value="550"/>
        <Setter Property="Height" Value="400"/>
        <Setter Property="MinWidth" Value="550"/>
        <Setter Property="MinHeight" Value="400"/>
        <Setter Property="ShowInTaskbar" Value="True"/>
        <Setter Property="Title" Value="{c:LocalizedString s_Settings}"/>
    </Style>

    <Style TargetType="{x:Type v:ErrorView}" BasedOn="{StaticResource FlashWindowBaseStyle}">
        <Setter Property="Width" Value="400"/>
        <Setter Property="MinWidth" Value="400"/>
        <Setter Property="ShowInTaskbar" Value="True"/>
        <Setter Property="Title" Value="{c:LocalizedString s_ShredTheLogError}"/>
        <Setter Property="SizeToContent" Value="Height"/>
        <Setter Property="ResizeMode" Value="NoResize"/>
    </Style>

    <Style TargetType="{x:Type v:InputView}" BasedOn="{StaticResource FlashWindowBaseStyle}">
        <Setter Property="Width" Value="300"/>
        <Setter Property="MinWidth" Value="300"/>
        <Setter Property="ShowInTaskbar" Value="True"/>
        <Setter Property="Title" Value="{Binding WindowTitle}"/>
        <Setter Property="SizeToContent" Value="Height"/>
        <Setter Property="ResizeMode" Value="NoResize"/>
    </Style>

    <Style TargetType="{x:Type v:MessageDialogView}" BasedOn="{StaticResource FlashWindowBaseStyle}">
        <Setter Property="Width" Value="300"/>
        <Setter Property="MinWidth" Value="300"/>
        <Setter Property="Height" Value="150"/>
        <Setter Property="MinHeight" Value="150"/>
        <Setter Property="ShowInTaskbar" Value="True"/>
        <Setter Property="Title" Value="{Binding WindowTitle}"/>
    </Style>

    <Style TargetType="{x:Type v:PrivateChatRequestView}" BasedOn="{StaticResource FlashWindowBaseStyle}">
        <Setter Property="Width" Value="300"/>
        <Setter Property="MinWidth" Value="300"/>
        <Setter Property="Height" Value="400"/>
        <Setter Property="MinHeight" Value="400"/>
        <Setter Property="ShowInTaskbar" Value="True"/>
        <Setter Property="Title" Value="{Binding Path=Caller.Name, StringFormat={c:LocalizedString s_PrivateChatRequestFrom}}"/>
    </Style>

    <Style TargetType="{x:Type v:UserSearchConditionsView}" BasedOn="{StaticResource FlashWindowBaseStyle}">
        <Setter Property="Width" Value="400"/>
        <Setter Property="MinWidth" Value="400"/>
        <Setter Property="SizeToContent" Value="Height"/>
        <Setter Property="ResizeMode" Value="NoResize"/>
        <Setter Property="ShowInTaskbar" Value="True"/>
        <Setter Property="Title" Value="{c:LocalizedString s_Conditions_UserSearch}"/>
    </Style>

</ResourceDictionary>